<template>
  <div class="barChart1"></div>
</template>

<script>
export default {
  props: ["config"],
  name: "",
  data() {
    return {};
  },
  methods: {
    setChart1() {
      let option = {
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "shadow",
          },
          backgroundColor: "rgba(11, 41, 116, 0.2)",
          borderColor: "rgba(11, 41, 116, 0.2)",
          textStyle: {
            color: "#fff",
          },
          padding: 0,
        },
        legend: {
          top: "bottom",
          left: "center",

          itemHeight: 10,
          textStyle: {
            color: "#fff",
          },
        },

        textStyle: {
          color: "#fff",
        },
        grid: {
          left: "3%",
          right: "4%",
          bottom: "10%",
          containLabel: true,
        },
        color: ["#db7289", "#5AD8A6", "#2391FF", "#FFC328"],
        xAxis: [
          {
            type: "category",
            data: this.config.xdata,
            axisLabel: {
              color: "#D6E1FF",
              fontSize: 12,
            },
            axisTick: {
              show: false,
            },
            splitLine: {
              show: false,
            },
            axisLine: {
              show: true, // 修改为 true 显示 x 轴线条
              lineStyle: {
                color: "#999",
              },
            },
          },
        ],
        yAxis: [
          {
            name: "",
            type: "value",
            axisLabel: {
              color: "#D6E1FF",
              fontSize: 12,
            },
            axisTick: {
              show: false,
            },
            splitLine: {
              show: true,
              lineStyle: {
                type: "dashed",
                color: "#9EA3B4",
                opacity: 0.1,
              },
            },
            axisLine: {
              show: false,
            },
          },
        ],
        series: [
          {
            name: this.config.series[0].name,
            type: "bar",
            stack: "user",
            itemStyle: {
              normal: {
                barBorderRadius: [0, 0, 0, 0],
              },
            },
            emphasis: {
              focus: "series",
            },
            barWidth: 30,
            data: this.config.series[0].data,
          },
          {
            name: this.config.series[1].name,
            type: "bar",
            stack: "user",
            itemStyle: {
              normal: {
                barBorderRadius: [0, 0, 0, 0],
              },
            },
            emphasis: {
              focus: "series",
            },
            barWidth: 30,
            data: this.config.series[1].data,
          },
          {
            name: this.config.series[2].name,
            type: "bar",
            stack: "user",
            itemStyle: {
              normal: {
                barBorderRadius: [0, 0, 0, 0],
              },
            },
            emphasis: {
              focus: "series",
            },
            barWidth: 30,
            data: this.config.series[2].data,
          },

          // {
          //   name: "其它",
          //   type: "bar",
          //   stack: "user",
          //   itemStyle: {
          //     normal: {
          //       barBorderRadius: [0, 0, 0, 0],
          //     },
          //   },
          //   emphasis: {
          //     focus: "series",
          //   },
          //   barWidth: 30,
          //   data: [3000, 4500, 3000, 1000, 3000, 5000, 3500],
          // },
        ],
      };
      let myChart = this.$echarts(this.$el);
      console.log("nnnnn");
      myChart.clear();
      myChart.resize();
      myChart.setOption(option);
    },
  },
  mounted() {
    this.setChart1();
  },
};
</script>

<style lang="less" scoped>
.barChart1 {
  width: 100%;
  margin-top: -5%;
  height: 100%;
}
</style>
